const router = require('koa-router')()
const {
    addFollow,
    cancelFollow,
    getFollowList
} = require('../controller/follow')

router.prefix('/api/follow')

//用户添加收藏
router.post('/add', async (ctx, next) => {
    const {
        userId,
        followId
    } = ctx.request.body
    console.log(JSON.stringify(ctx.request.body));
    ctx.body = await addFollow({
        userId,
        followId
    })
})

//用户取消收藏
router.post('/cancel', async (ctx, next) => {
    console.log(JSON.stringify(ctx.request.body));
    const {
        userId,
        followId
    } = ctx.request.body
    ctx.body = await cancelFollow({
        userId,
        followId
    })

})

//用户收藏列表
router.get('/list',async (ctx,next)=>{
    const userId = ctx.query.userId
    ctx.body = await getFollowList(userId)
})

module.exports = router
